﻿using blackhouse.BlackApart.Business.Apartments;
using blackhouse.Locations;
using blackhouse.WebNemo.Business.Groups;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace blackhouse.BlackApart.WebNemo {
    public class NemoLocation : GroupRecord, IApartmentLocation {

        #region Fields

        private GroupRecord cityRecord;
        private GroupRecord districtRecord;

        #endregion

        #region Properties

        public int Id {
            get { return this.RecordId; }
        }

        public Location Localization {
            get {
                Location location = new Location();
                location.Latitude = this.GetDouble("latitude");
                location.Longitude = this.GetDouble("longitude");
                return location;
            }
            set { throw new NotImplementedException(); }
        }

        public string LocationName {
            get { return this.GetString("nazwa_lokalizacji"); }
            set { throw new NotImplementedException(); }
        }

        public int CityId {
            get { return this.CityRecord.RecordId; }
            set { throw new NotImplementedException(); }
        }

        public string City {
            get { return this.CityRecord.GetString("miasto"); }
            set { throw new NotImplementedException(); }
        }

        public int DistrictId {
            get { return this.DistrictRecord.RecordId; }
            set { throw new NotImplementedException(); }
        }

        public string District {
            get { return this.DistrictRecord.GetString("dzielnica"); }
            set { throw new NotImplementedException(); }
        }

        private GroupRecord CityRecord {
            get {
                if (this.cityRecord == null)
                    this.cityRecord = this.GetRecord("miasto");
                return this.cityRecord;
            }
        }

        private GroupRecord DistrictRecord {
            get {
                if (this.districtRecord == null)
                    this.districtRecord = this.GetRecord("dzielnica");
                return this.districtRecord;
            }
        }

        #endregion

        #region Constructors

        public NemoLocation(int locationId) : base("LOKALIZACJA", locationId) { }

        public NemoLocation() { }

        #endregion

        #region Methods

        public new bool Save() {
            throw new NotImplementedException();
        }

        #endregion

    }
}
